package Servlets;
import java.io.PrintWriter;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import queryClass.Queries;

import DB.DAOManager;

public class RetrievePoll extends HttpServlet{

	public void doGet(HttpServletRequest req, HttpServletResponse res)
			throws IOException, ServletException {
		try{
			doPost(req, res);
		}
		catch(Exception e){
			
		}
	}///do get///////
	public void doPost(HttpServletRequest req, HttpServletResponse res)
	
			throws IOException, ServletException {
		try {
			PrintWriter out=res.getWriter();
			System.out.println("Retrieving poll !!!!");
			DAOManager dao=new DAOManager();
			Connection conn=dao.getConnection();
			////System.out.println("boooooooooooooo");
			PreparedStatement pstmt=conn.prepareStatement(Queries.retrievepoll);

			ResultSet rs=pstmt.executeQuery();
			while(rs.next()){
				out.println(rs.getString("pollQuestion"));
				System.out.println(rs.getString("pollQuestion"));

			}
		
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
}
